package shiwenhui.com.taotao.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import shiwenhui.com.taotao.common.pojo.EUDataGridResult;
import shiwenhui.com.taotao.common.pojo.TaotaoResult;
import shiwenhui.com.taotao.pojo.TbItem;
import shiwenhui.com.taotao.service.ItemService;

/**
 * 商品管理Controller
 */


@Controller
public class ItemController {

    @Autowired
    private ItemService itemService;

    @RequestMapping("/item/{itemId}")
    @ResponseBody
    public TbItem getItemById(@PathVariable Long itemId)
    {
        TbItem tbItem = itemService.getItemById(itemId);
        return tbItem;
    }

    @RequestMapping("/item/list")
    @ResponseBody
    public EUDataGridResult getItemList(Integer page, Integer rows)
    {
        EUDataGridResult result = itemService.getItemList(page, rows);
        return result;
    }


    @RequestMapping(value="/item/save", method= RequestMethod.POST)
    @ResponseBody
    private TaotaoResult createItem(TbItem item, String desc, String itemParams) throws Exception {
//    private TaotaoResult createItem(TbItem item,String desc) throws Exception {
        TaotaoResult result = itemService.createItem(item,desc,itemParams);
        return result;
    }


}
